﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;
using System.Text;
using System.Configuration;

namespace FBKPI.Tools.LogWriter
{
    public class LogWriter
    {
        public void WriteLog(string ErrorMsg, string ErrorStackTrace)
        {
            string logpath = ConfigurationManager.AppSettings["LogPath"];
            string logfilename = "Log_" + DateTime.Now.Date.ToShortDateString().Replace("/", "") + ".txt";

            if (!Directory.Exists(logpath))
                Directory.CreateDirectory(logpath);

            using (StreamWriter writer = new StreamWriter(logpath + logfilename, true))
            {
                writer.WriteLine("*****************");
                writer.WriteLine("ERRORDATE : " + DateTime.Now.ToString());
                writer.WriteLine("ERRORMSG  : " + ErrorMsg);
                writer.WriteLine("ERRORSTC  : " + ErrorStackTrace);
                writer.WriteLine("*****************");
            }
        }
    }
}